package view;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
import model.GpsCoordinate;
import model.Map;
import model.Route;
import model.RouteWaypoint;

public class PoiMarkersViewDecorator extends ViewDecorator {
    
    private Map map;
    private Route route;
    
    public PoiMarkersViewDecorator(JComponent component, Map map, Route route) {
        super(component);
        this.map = map;
        this.route = route;
    }
    
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.setColor(Color.PINK);
        
        List<RouteWaypoint> pointsOfInterest = route.getPointOfInterests();
        Iterator<RouteWaypoint> itr = pointsOfInterest.iterator();
        
        while (itr.hasNext()) {
            GpsCoordinate coord = itr.next().getGpsCoordinate();
            Point coordPoint = new Point(MapViewUtil.calculateXpixels(map, coord),
                                        MapViewUtil.calculateYpixels(map, coord));
            
            g2d.setColor(Color.YELLOW);
            g2d.fillOval(coordPoint.x - 5,
                        coordPoint.y - 5,
                        10,
                        10);
            
            g2d.setColor(Color.BLUE);
            g2d.drawOval(coordPoint.x - 5,
                        coordPoint.y - 5,
                        10,
                        10);
        }
    }
    
}